package com.daify.threadlearn.chapter01.order04;

import java.util.HashSet;
import java.util.Queue;
import java.util.Random;
import java.util.Set;

/**
 * @author daify
 * @date 2019-06-06
 */
public class HiddenIterator {

    private final Set<Integer> set = new HashSet<Integer>();

    public synchronized void add(Integer i) {
        set.add(i);
    }

    public synchronized void remove(Integer i) {
        set.remove(i);
    }

    public void addTenThings() {
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            add(random.nextInt());
            System.out.println("debug:" + set);
        }
    }


    public static void main(String[] args) {
        HiddenIterator iterator = new HiddenIterator();
        iterator.addTenThings();
    }
}
